//
//  ZTacticsTableViewCell.m
//  DoctorFAQs
//
//  Created by zjq on 17/2/20.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZTacticsTableViewCell.h"
#import "ZLabelTools.h"
#import "ZDotorFreshView.h"
#import "LZTacticsModel.h"

@interface ZTacticsTableViewCell ()<ZDotorFreshDeleGate>{
    UIView * _whiteView;
    UILabel * _titleLabel;
    UILabel * _timeLabel;
    UIImageView * _imageView;
    ZDotorFreshView * _doctorView;
}

@end
@implementation ZTacticsTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initlizeInterface];
    }
    return self;
}
- (void)initlizeInterface {
    self.backgroundColor = MYGRAYCOLOR;
    [self makeSubView];
    [self addAllSubView];
    [self makeAllSubViewmasnoy];
}
- (void)makeSubView {
    _whiteView = [[UIView alloc] init];
    _whiteView.backgroundColor = [UIColor whiteColor];
    _whiteView.layer.cornerRadius = 2.0f;
    _whiteView.layer.masksToBounds = YES;
    _titleLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_titleLabel Textcolor:[UIColor blackColor] backColor:[UIColor clearColor] Fontsize:18 context:@"" isCenter:NO];
    _timeLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_timeLabel Textcolor:KHGaryColor backColor:[UIColor clearColor] Fontsize:12 context:@"" isCenter:NO];
    _imageView = [[UIImageView alloc] init];
    
    _doctorView = [[ZDotorFreshView alloc] init];
    _doctorView.ZDFDelegate = self;
}
- (void)addAllSubView {
    [self.contentView addSubview:_whiteView];
    [self.contentView addSubview:_titleLabel];
    [self.contentView addSubview:_timeLabel];
    [self.contentView addSubview:_imageView];
    [self.contentView addSubview:_doctorView];
    
    
}
- (void)makeAllSubViewmasnoy {
    [_whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10*xsIZE);
        make.right.equalTo(self.contentView).offset(-10*xsIZE);
        make.top.equalTo(self.contentView).offset(10*ysIZE);
        make.bottom.equalTo(self.contentView);
    }];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_whiteView).offset(10*xsIZE);
        make.right.equalTo(_whiteView).offset(-10*xsIZE);
        make.height.offset(18*ysIZE);
        make.top.equalTo(_whiteView).offset(15*ysIZE);
    }];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.equalTo(_titleLabel);
        make.height.offset(12*ysIZE);
        make.top.equalTo(_titleLabel.mas_bottom).offset(10*ysIZE);
    }];
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.equalTo(_timeLabel);
    
        make.height.offset(135*ysIZE);
        make.top.equalTo(_timeLabel.mas_bottom).offset(10*ysIZE);
    }];
    [_doctorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.equalTo(_whiteView);
        make.height.offset(35*ysIZE);
        make.top.equalTo(_imageView.mas_bottom).offset(5*ysIZE);
    }];
}
- (void)jumpDoctorViewController {
    !self.GoDFBlock? : self.GoDFBlock();
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

// 医生模型set方法
- (void)setDoctorModel:(DoctorModel *)doctorModel {
    _doctorModel = doctorModel;
    _doctorView.doctorModel = doctorModel;
    
}

// 就医策略模型set方法
- (void)setTacticsModel:(LZTacticsModel *)tacticsModel {
    _tacticsModel = tacticsModel;
    _titleLabel.text = tacticsModel.title;
    
    NSString * str = tacticsModel.time;
    NSTimeInterval time = [str doubleValue];
    NSDate *detaildate = [NSDate dateWithTimeIntervalSince1970:time];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"];
    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
    //转化时间戳
    //self.create_time = currentDateStr;
    _timeLabel.text = currentDateStr;
    NSString *iconStr = [NSString stringWithFormat:@"%@%@",IconURL,tacticsModel.cover];
    [_imageView sd_setImageWithURL:[NSURL URLWithString:iconStr] placeholderImage:[UIImage imageNamed:@""]];
    
}


@end
